package com.linwen.javase;

/**
 * @author : linwen
 * @date : 下午4:38 2021/3/7
 */
public class MyEnum {
    public static void main(String[] args) {
        Season spring = Season.SPRING;
        System.out.println(spring);
        Season1 spring1 = Season1.SPRING;
        System.out.println(spring1);
        Season1.WINTER.show();
    }
}
//自定义一个枚举类  类的对象都用 public static final来定义
class Season{
    private final String season;

    private Season(String name){
        this.season = name;
    }

    public String getSeason() {
        return season;
    }
    public static final Season SPRING = new Season("SPRING");
    public static final Season SUMMER = new Season("SUMMER");
    public static final Season AUTOMN = new Season("AUTOMN");
    public static final Season WINTER = new Season("WINTER");

    @Override
    public String toString() {
        return "Season{" +
                "season='" + season + '\'' +
                '}';
    }
}

interface Info{
    public void show();
}
//enum实现接口，需要每个对象自己实现自己的方法
enum Season1 implements Info{
    SPRING{
        @Override
        public void show() {
            System.out.println("春天");
        }
    },
    SUMMER{
        @Override
        public void show() {
            System.out.println("夏天");
        }
    },
    AUTOMN{
        @Override
        public void show() {
            System.out.println("秋天");
        }
    },
    WINTER{
        @Override
        public void show() {
            System.out.println("冬天");
        }
    };

}
